package com.coffeeloversupportlibrary.coffeelover.domain.coffeebean.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.coffeeloversupportlibrary.R;
import com.coffeeloversupportlibrary.coffeelover.domain.article.entity.Article;
import com.coffeeloversupportlibrary.databinding.BeansContentListItemBinding;

import java.util.List;

/**
 * @author puyv
 * @createTime 2021/11/12 13:02
 * @projectName CoffeeLoverSupportLibrary
 * @className BeansListAdapter.java
 * @description TODO
 */
public class BeansListAdapter extends RecyclerView.Adapter {
    private List<Article> lists;
    private BeansContentListItemBinding beansContentListItemBinding;

    public BeansListAdapter(List<Article> list){
        this.lists=list;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.beans_content_list_item,parent,false);
        beansContentListItemBinding= DataBindingUtil.bind(view);
        return new BeanItemViewHolder(beansContentListItemBinding);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        Article article=lists.get(position);
//        beansContentListItemBinding.beanImageItem.setImageResource(article.getImageTest());
    }

    @Override
    public int getItemCount()
    {
        return lists.size();
    }

    static class BeanItemViewHolder extends RecyclerView.ViewHolder{
        BeansContentListItemBinding beansContentListItemBinding;
        public BeanItemViewHolder(@NonNull BeansContentListItemBinding beansContentListItemBinding) {
            super(beansContentListItemBinding.getRoot());
            this.beansContentListItemBinding=beansContentListItemBinding;
        }
    }
}
